<template>
  <h3>子组件</h3>
  <h3>{{ msg }}</h3>
  <button @click="update">更新-自组件</button>
</template>
<script lang="ts">
import { defineComponent, reactive } from "vue";
export default defineComponent({
  name: "child",
  props: ["msg"],
  emits: ["updateMsg"],
  setup(props, context) {
    const user = reactive({
      name: '咕咕',
      age: 21,
      hobby: ['play', 'code']
    })
    console.log("msg  =", props.msg);

    console.log("context");
    console.log(context);

    console.log("attrs");
    console.log(context.attrs);

    function update() {
      context.emit("updateMsg", "子传父");
    }
    return {
      update,
      user
    };
  },
});
</script>
